package com.itheima;

import com.itheima.service.UserServiceImpl;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;

public class Server {

    public static void main(String[] args) {

        //创建发布服务的工厂
        JAXRSServerFactoryBean jaxrsServerFactoryBean = new JAXRSServerFactoryBean();

        //设置服务地址
        jaxrsServerFactoryBean.setAddress("http://localhost:8001/ws");

        //设置服务类
        jaxrsServerFactoryBean.setServiceBean(new UserServiceImpl());

        //添加日志输入输出拦截器
        jaxrsServerFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
        jaxrsServerFactoryBean.getInInterceptors().add(new LoggingOutInterceptor());

        //发布服务
        jaxrsServerFactoryBean.create();

        System.out.println("发布服务成功，端口8001");

    }

}
